package 集合.day3.demo1;

import java.util.*;

public class Test1 {
    public static void main(String[] args) {
        HashSet hs =new HashSet();
        System.out.println(hs.add("aaa"));
        Map<String,String> m=new HashMap<>();
        m.put("张三","139");
        m.put("李四","159");
        m.put("王五","136");

        //方法一：keySet
        Set<String> keys=m.keySet();
        for(String k:keys){
            System.out.println(k+"="+m.get(k));
        }
        //方法二：values
        Collection<String> values=m.values();
        for(String v:values){
            System.out.println(v);
        }

        //方法三：entrySet
        System.out.println("========entrySet==========");
        Set<Map.Entry<String,String>> entries=m.entrySet();
        for(Map.Entry e:entries){
            System.out.println(e.getKey()+"="+e.getValue());
        }

        Iterator<Map.Entry<String,String>> it=entries.iterator();
        while (it.hasNext()){
            Map.Entry e=it.next();
            System.out.println(e.getKey()+"="+e.getValue());
        }


    }
}
